
<link rel="stylesheet" href="__ADMIN__/ace/css/ui.jqgrid.css" />
<div class="modal fade" tabindex="-1" role="dialog" id="carModal">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
            aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">选择车辆信息</h4>
      </div>
      <div class="modal-body">
        <table id="tbCar" class="table"></table>
        <div id="tbCarPager"></div>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
  var $jqGrid=$('#tbCar'),$pager=$('#tbCarPager');
  $jqGrid.jqGrid({
    url:"{:url('getCars')}",
    datatype:'json',
    mttype:'post',
    colNames:['操作','车牌号','车型','公里数','车架号'],
    colModel:[
      {name:'car_num',index:'car_num',width:'100',align:'center',formatter:function(value,options,obj){
//        console.log(obj);
        return '<a carnum="'+obj.car_num+'" cartype="'+obj.car_type+'" mileage="'+obj.mileage+'" vin="'+obj.vin+'" onclick="chooseCar.chooseConfirm(this)">选择</a>';
      }},
      {name:'car_num',index:'car_num',width:'100',align:'center'},
      {name:'car_type',index:'car_type',width:'100',align:'center'},
      {name:'mileage',index:'mileage',width:'100',align:'center'},
      {name:'vin',index:'vin',width:'100',align:'center'},
    ],
    height:'auto',
    pager: '#tbCarPager',
    viewrecords:true,
    rowNum:10,
    rowList:[10,20,40],
    autowidth:true
  });

  $('#btnSearch').click(function(){
    var q=$('#txtQuery').val();
    $jqGrid.jqGrid('setGridParam',{
      postData:{q:q},
      page:1
    }).trigger("reloadGrid");
  });

  chooseCar={
    chooseConfirm:function(obj){
      var car_num=$(obj).attr('carnum');
      var car_type=$(obj).attr('cartype');
      var mileage=$(obj).attr('mileage');
      var vin=$(obj).attr('vin');
      var html='<li><span>车牌号：</span>'+car_num+'</li>';
      html+='<li><span>&nbsp;&nbsp;&nbsp;车型：</span>'+car_type+'</li>';
      html+='<li><span>公里数：</span>'+mileage+'</li>';
      html+='<li><span>车架号：</span>'+vin+'</li>';
      invoiceModal.carNum=car_num;
//        console.log(html);
      $('.info-vehicle-hook').html(html);
      $('#carModal').modal('hide');

    }
  }
</script>


